const static_resource_manage = require('./static_resource_manage.js');
const article_server = require('./article_server.js');
const source_code_server = require('./source_code_server.js');
const path = require('path');
const htmlConfig = require('./config/htmlConfig.js');

let expressMobile = function (app,prefix,dist_prod) {
    /*给手机端提供后台支持*/
    /*添加静态资源*/
    /*这个静态资源直接加在localhost后面就能读取,以后研究下原因*/
    static_resource_manage.add(prefix,path.resolve('../img/'));
    static_resource_manage.add(prefix,path.resolve('../img/background'));
    static_resource_manage.add(prefix,path.resolve('../img/mobileImg'));
    static_resource_manage.add(prefix,path.resolve(dist_prod));
    static_resource_manage.add(prefix,path.resolve(dist_prod));
    article_server(app,prefix);
    source_code_server(app,prefix);

    app.post('/img/:name',function (req,res) {
        res.send(prefix+req.params.name)
    });

    app.post('/source_code',function (req,res) {
        res.send(prefix+htmlConfig.mSource_code);
    });

    app.post('/article',function (req,res) {
        res.send(prefix+htmlConfig.mArticle);
    })
};

module.exports = expressMobile;